/**
 * *************************************
 * Copyright(c)2016 Dingdang Yixia 
 * All Rights Reserved.
 *
 * @File: NoticeController.java
 * @Package: com.ddyx.rest
 * @Description:
 * 
 * @Version: V1.0
 * @Author: Yidong.Xiang
 * @Date: 2017年8月24日 下午10:15:22
 * 
 * *************************************
 */
package com.ddyx.rest;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ddyx.service.IFaceNotifyService;

/**
 * @ClassName: NoticeController.java
 * @Module: 
 * @Description: 
 * 
 * @author: Yidong.Xiang
 * @date: 2017年8月24日 下午10:15:22
 * 
 */
@Controller
@RequestMapping("/notice/saveface")
public class SaveFaceNoticeController {

	@Resource
	IFaceNotifyService saveFaceNotifyServie;

	/**
	 * 启动人脸识别消息队列监听
	 * @return
	 */
	@RequestMapping(params = "cmd=startListen", method = RequestMethod.GET)
	public @ResponseBody String startListen()
	{
		if(saveFaceNotifyServie.isRunning()==false)
		{
			saveFaceNotifyServie.startListen();
			return "running......";
		}else return "is running";
	}
	
	/**
	 * 启动人脸识别消息队列监听（带时间参数）
	 * @param interval	接收消息时间间隔，单位毫秒
	 * @param sleep	线程睡眠时间，单位毫秒
	 * @return
	 */
	@RequestMapping(params = "cmd=startup", method = RequestMethod.GET)
	public @ResponseBody String startup(@RequestParam("receive") int interval
			,@RequestParam("sleep") int sleep)
	{
		if(saveFaceNotifyServie.isRunning()==false)
		{
			saveFaceNotifyServie.startListen(interval, sleep);
			return "running......";
		}else return "is running";
	}	
	/**
	 * 关闭人脸识别消息队列监听
	 * @return
	 */
	@RequestMapping(params = "cmd=stopListen", method = RequestMethod.GET)
	public @ResponseBody String stopListen()
	{
		if(saveFaceNotifyServie.isRunning()==true)
			saveFaceNotifyServie.stopListen();
		return "is closed";
	}
}
